<include file="Finance:leftmenu" />
<div class="content-right fl">
    <h1 class="content-right-title">奖金流水</h1>
    
    <div class="tablesWrap">
    

        <form action="" method="get" name="form1">
            <div class="tables-searchbox">
                <input type="text" class="input" name="order_id" id="order_id" value="<?php echo get('order_id');?>" placeholder="订单ID">
                <input type="text" class="input" name="user_id" id="user_id" value="<?php echo get('user_id');?>" placeholder="用户ID">

			<select name="logtype" class="select mini" id="logtype">
				<option value="" <?php echo (get("logtype") == "") ? "selected" : "";?> >类型</option>
				<option value="0" <?php echo (get("logtype") == "0" && (get("logtype") !='')) ? "selected" : "";?> >支出</option>
				<option value="1" <?php echo (get("logtype") == "1") ? "selected" : "";?> >收入</option>
			</select>


                <button class="btn btn-primary"><i class="gicon-search white"></i>查询</button>
                <a href="/admin/finance/jiangjin" class="btn btn-warning">清除查询</a>
                
<a class="btn btn-success " href="javascript:excel();"><i class="gicon-share white"></i>导出</a>

                <input type="hidden" name="action" value="">
            </div>
        </form>
  
        <!-- 0全部 1车房 2领导 3分红  -->
	<div class="tabs clearfix mgt15 tabs-width order-numbers">
		<a href="/admin/finance/jiangjin/type/0<?php echo $params;?>" class="<?php echo (!$type)?'active':'';?> tabs_a fl">全部奖金</a>
		<a href="/admin/finance/jiangjin/type/1<?php echo $params;?>" class="<?php echo ($type == 1)?'active':'';?> tabs_a fl">车房奖</a>
		<a href="/admin/finance/jiangjin/type/2<?php echo $params;?>" class="<?php echo ($type == 2)?'active':'';?> tabs_a fl">领导奖</a> 
		<a href="/admin/finance/jiangjin/type/3<?php echo $params;?>" class="<?php echo ($type == 3)?'active':'';?> tabs_a fl">分红奖</a>
	</div>
        <table class="wxtables">
         	<colgroup>
         		<col width="3%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
                <col width="6%">
            </colgroup>
            <thead>
            <tr>
                <td>编号</td>
                <td>用户id</td>
                <td>用户姓名</td>
                <td>奖金类型</td>
                <td>类型</td>
                <td>订单金额</td>
                <td>奖金/分红金额</td>
                <td>订单号</td>
                <td>创建时间</td>
            </tr>
            </thead>
            <tbody>
            
            
<?php foreach($datalist as $k=>$v){ ?>
            <tr>
                <td><?php echo $v['log_id'];?></td>
                <td><a style="color:blue;" href="/admin/member/index?user_id=<?php echo $v['uid'];?>" target="_blank"><?php echo $v['uid'];?></a></td>
                <td><?php echo $v['realname']?$v['realname']:$v['nickname']; ?></td>
                <td><?php switch($v['mtype']){case 6:echo '车房奖';break;case 7:echo '领导奖';break;case 8:echo '分红奖';break;  } ?></td>
                <td><?php echo $v['logtype'] ? "<span style='color:red'>收入</span>" : "<span style='color:green'>支出</span>";?></td>
                <td><?php echo $v['order_paymoney'] ?></td>
                <td><?php echo $v['money'] ?></td>
                <td><a style="color:blue;" href="/admin/order/index/status/7?order_id=<?php echo $v['order_id'];?>" target="_blank"><?php echo $v['order_id'];?></a></td>
                <td><?php echo $v['pay_time']?$v['pay_time']:($v['order_time'] ? $v['order_time'] : $v['create_time']);?></td>

</tr>
<?php } ?>                         
              
                            </tbody>
        </table>
	<div class="tables-btmctrl clearfix">
           <div class="mgt10">
               <div class="paginate">
                  {$page}
               </div>
           </div>
	</div>
    </div>

</div>

<script>

function excel(){

	var order_id = $("#order_id").val();
	var user_id = $("#user_id").val();
	var logtype = $("#logtype").val();

	var url = "/admin/finance/liushuiexcel/?mtype=1&user_id="
			+user_id+"&logtype="+logtype+"&order_id="+order_id;
	
	var url_1 = "/admin/finance/liushuiexcelpage/?mtype=1&user_id="
		+user_id+"&logtype="+logtype+"&order_id="+order_id;
	
	layer.msg('正在导出,请耐心等待...', {icon: 16});
	
	//分页信息
	//查找页数
	$.ajax({
		url : url_1,
		type : "GET",
		dataType : 'json',
	//	async: false,
		success : function(data) {
			
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}

			layer.msg(data.msg, {icon: messagetype},function(){

				if(data.data==0){
					layer.msg("无数据", {icon: 2});
				}else if(data.data>0){

					var html = '<div style="padding:50px;">';
					for(i=1;i<=data.data;i++){

						var haha = url+"&p="+i;
						

						html += '<br><a href="'+haha+'" target="_blank" style="font-size:20px">下载'+i+'</a><br>';
						
						
					}
					
					html += '</div>';
					
					layer.open({
						title:"请分别点击下面的链接下载文件,每个文件最多包含5000条数据",
					    type: 1,
					    skin: 'layui-layer-rim', //加上边框
					    area: ['500px', '500px'], //宽高
					    content: html
					});
					
					
				}
				
			});
		},
		beforeSend:function(){
			layer.closeAll();//关闭
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
	//window.location.href = url;
	
}

</script>